-- --metatable

-- player1={}
-- player2={blood=50}

-- player={
--     __index={
--         age=10,
--         blood=100,
--         run=function()
--             print("this is run")
--         end
--     }
-- }

-- setmetatable(player1,player)
-- setmetatable(player2,player)

-- print("blood="..player1.blood)
-- print("blood="..player2.blood)

-- player1.run()
-- player2.run()


--method
player1={}
player2={}

player={
    __index=function(player,indexName)
        print(indexName)
        if indexName=="blood"
        then
            return 100
        elseif indexName =="age"
        then
            return 20
        end
    end
}

setmetatable(player1,player)

print("blood="..player1.blood)
print("age="..player1.age)